package com.egitim.cati.form;


import javax.inject.Inject;

import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.IdentityImpl;

 
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.PasswordTextField;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;

public class LoginForm extends Form<Credentials> {
    
    	 /**
		 * 
		 */

		private static final long serialVersionUID = 1L;
    	  @Inject IdentityImpl identity;
        public LoginForm(String id,  Credentials credentials) {
             super(id, new CompoundPropertyModel<Credentials>(credentials));
            add(new TextField<String>("username"));
            add(new PasswordTextField("password"));
        }
     
        protected void onSubmit() {
            try {
                identity.logout();
                identity.login();
                if(identity.isLoggedIn())
                	  {           
		                	//throw new RestartResponseAtInterceptPageException(WebSite.class);   
		                	//System.out.println("GIRDIN........................");
                	} else{
                			//System.out.println("GIREMEDIN........................");
                	}
               
            } catch (Exception e) {
            	
                error("Login failed");                    
            }
        }   
    }
 